<!doctype html>
<html>
<head>
<title>网站内容发布后台</title>
<style type="text/css">
#loading-mask {
	background-color: white;
	height: 100%;
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	z-index: 20000;
}

#loading {
	height: auto;
	position: absolute;
	left: 45%;
	top: 40%;
	padding: 2px;
	z-index: 20001;
}

#loading a {
	color: #225588;
}

#loading .loading-indicator {
	background: white;
	color: #444;
	font: bold 13px Helvetica, Arial, sans-serif;
	height: auto;
	margin: 0;
	padding: 10px;
}

#loading-msg {
	font-size: 10px;
	font-weight: normal;
}

#header {
	height:25px;
    background: url("${resource(dir:'js/extjs/resources/images',file: 'layout-browser-hd-bg.gif')}") repeat-x scroll center center #7F99BE;
    color:white;
}

.menu_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'icon_menu.gif')}) !important;
}

.content_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'icon_content.gif')}) !important;
}

.page_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'page.gif')}) !important;
}

.user_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'user.gif')}) !important;
}

.pwd_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'pwd.gif')}) !important;
}
.add_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'add.png')}) !important;
}

.del_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'delete.gif')}) !important;
}

.save_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'save.gif')}) !important;
}

.choose_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'choose.png')}) !important;
}

.top_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'top.png')}) !important;
}

.refresh_icon{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'refresh.gif')}) !important;
}

.system_icon_menu{
		background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'folder.gif')}) !important;
}

.content_icon_menu{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'content.gif')}) !important;
}

.link_icon_menu{
	background-image: url(${resource(dir:'js/extjs/resources/icon',file: 'link.gif')}) !important;
}
</style>

</head>
<body>
	<div id="loading-mask" ></div>
	<div id="loading">
		<div class="loading-indicator">
		<img src="${resource(dir:'js/extjs/resources/images',file:'init_loading.gif')}" width="32" height="32" style="margin-right:8px;float:left;vertical-align:top;"/>
			网站管理后台 <br />
			<span id="loading-msg">载入页面内容...</span>
		</div>
	</div>

	<link rel="stylesheet" type="text/css"
		href="${resource(dir:'js/extjs/resources/css/',file:'ext-all.css')}" />
		
		<script type="text/javascript">
			User = ${SessionUser}
			if(!User.name)
				User.name = "管理员"
		</script>

        <script type="text/javascript">document.getElementById('loading-msg').innerHTML = '载入核心脚本';</script>
        <script type="text/javascript" src="${resource(dir:'js/extjs',file:'ext-base.js')}"></script>
        <script type="text/javascript">document.getElementById('loading-msg').innerHTML = '载入页面组件';</script>
        <script type="text/javascript" src="${resource(dir:'js/extjs',file:'ext-all-debug.js')}"></script>
        <script type="text/javascript" src="${resource(dir:'js/extjs',file:'ext-lang-zh_CN.js')}"></script>
        <script type="text/javascript" src="${resource(dir:'js/extjs',file:'ux.js')}"></script>
	 	
	 	<script type="text/javascript" src="${resource(dir:'js',file:'jquery-1.4a2.min.js')}"></script>
	 	<script type="text/javascript" src="/inspector/xheditor/xheditor-1.1.13-zh-cn.js"></script>
 		<script type="text/javascript" src="/inspector/js/extjs/xheditor.js"></script>
 		<!-- 
 	 	<script type="text/javascript" src="${resource(dir:'xheditor',file:'xheditor-1.1.13-zh-cn.min.js')}"></script>
  	 	<script type="text/javascript" src="${resource(dir:'js/extjs',file:'xheditor.js')}"></script>
 		  -->
        <script type="text/javascript">document.getElementById('loading-msg').innerHTML = '初始化页面...';</script>
		<script type="text/javascript" src="${resource(dir:'js/extjs',file:'app.js')}"></script>
		<script type="text/javascript">
			Ext.get('loading').hide()
			Ext.get('loading-mask').hide()
			
			var loginWin = new Ext.Window({
			    title: '网站后台登录',
			    iconCls: 'user_icon',
			    modal: true,
			    width: 300,
			    height: 130,
			    layout: 'fit',
			    bodyStyle: 'padding:5px;',
			    buttonAlign: 'center',
			    closable: false,
			    items: [{
			        id: 'loginForm',
			        xtype: 'form',
			        border: false,
			        
			        items: [{
			            id: 'loginNameField',
			            xtype: 'textfield',
			            fieldLabel: '用户名',
			            name: 'loginId',
			            allowBlank: false
			        }, {
			            xtype: 'textfield',
			            fieldLabel: '密码',
			            name: 'pwd',
			            inputType: 'password',
			            allowBlank: false
			        }],
			        buttons: [{
			            text: '登录',
			            inputType: 'submit',
			            handler: function(){
			                if (Ext.getCmp('loginForm').getForm().isValid()) {
			           
			                    Ext.Ajax.request({
			                        url: '/inspector/admin/login',
			                        params: Ext.getCmp('loginForm').getForm().getValues(),
			                        success: function(resp, opts){
			                            var r = Ext.util.JSON.decode(resp.responseText)
			                            if (r.success) {
			                                User = r.user
			                                showApp()
			                                loginWin.destroy()
			                            }
			                            else 
			                                alert("登录失败：" + r.msg)
			                        },
			                        failure: function(respTxt){
			                            alert("发送请求失败")
			                        }
			                    })
			                }
			            }
			        }]     /**/
			    }],
			    listeners: {
			        show: function(){
			            Ext.getCmp("loginNameField").focus('登录名',100)
			        }
			    }
			})

			if(User.role){
				showApp()
			}else{
				loginWin.show()
			}

			function logout(){
			    Ext.Msg.confirm("确认退出吗？", "您将丢失页面所有信息？", function(){
			        Ext.Ajax.request({
			            url: '/inspector/admin/logout',
			            success: function(resp, opts){
			                var r = Ext.util.JSON.decode(resp.responseText);
			                if (r.success) {
			                    window.location.href = window.location.href
			                }
			                else 
			                    alert("退出失败 " + r.msg)
			            },
			            failure: function(respTxt){
			                alert("发送请求失败")
			            }
			        })
			    })
			}
		</script>
</body>

</html>